home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / mini / DHCPcd < prev    next >
Text File  |  1997-03-16  |  15KB  |  716 lines

  1.  
  2. How to setup Linux as DHCP client
  3.  
  4.    
  5.    
  6.    
  7.      _________________________________________________________________
  8.    
  9.    
  10.    
  11.    _Disclaimer:_ The information contained herein is NOT official
  12.    information of any kind and there are no warranties to the accuracy of
  13.    the data. All information is provided in good faith. Use at your own
  14.    risk.
  15.    
  16.    
  17.      _________________________________________________________________
  18.    
  19.    Vladimir Vuksan, vuksan@veus.hr
  20.    $Id: dhcp.html,v 1.2 1998/03/02 23:29:24 vuksan Exp $
  21.    
  22.   Introduction
  23.   
  24.    
  25.    
  26.    This HOWTO explains how to setup your Linux system to work in a DHCP
  27.    environment as a client (DHCPcd). If you are looking for a DHCP server
  28.    you need to read DHCPd mini-HOWTO at
  29.    http://sunsite.unc.edu/LDP/HOWTO/mini/DHCPd. DHCP is a protocol that
  30.    allows a client machine to obtain network information from a server.
  31.    Many organizations are starting to use it because it eases network
  32.    administration especially in large networks or networks which have
  33.    lots of mobile users. DHCP is also being heavily used by cable
  34.    Internet service provider such as MediaOne Express, Time Warner etc.
  35.    More info about DHCP can be found in DHCP FAQ.
  36.    
  37.   Road Runner Service
  38.   
  39.    If you have Road Runner cable service check out
  40.    http://people.qualcomm.com/karn/rr/index.html. If that doesn't solve
  41.    your problem try following.
  42.    
  43.   2.1.x kernels
  44.   
  45.    If you are running a > 2.1.30 kernel (don't remember the exact number
  46.    and www.linuxhq.com is down currently) you might encounter a problem
  47.    with the dhcpc. According to Dan Khabaza:
  48.    _"The changes are due to differences in ipv4 network package, in the
  49.    way it sets the defaults for several fields."_
  50.    
  51.    Dan has provided a patch for it that can be obtained at
  52.    http://www.cro.net/~vuksan/dhcppatch. To apply it just copy it to the
  53.    dhcpcd source directory (instruction how to get source are in the
  54.    following section) and type
  55.    
  56. patch
  57.  
  58.  
  59.  
  60.  
  61. dhcpcd should compile cleanly after the patch has been applied. Note that
  62. this patch works only against dhcpcd 0.65 :-(.
  63.  
  64.  
  65.  
  66.  
  67. Another patch has been provided by
  68. Paul Rossington if you
  69. have problems with the one above. It is actually the whole if.C file. Get
  70. it at
  71. http://www.cro.net/~vuksan/if.C
  72. and copy it to the dhcpcd source directory.
  73.  
  74.  
  75.  
  76.  
  77. Other alternative when running 2.1.x kernels is to use dhcpcd 1.3.3 which is
  78. a modified version that has been written by Sergei Viznyuk
  79. sergei@phystech.com in order to avoid
  80. problems with 2.1.x kernels. You can fetch it at:
  81.  
  82.  
  83.  
  84.  
  85. http://www.cps.msu.edu/~dunham/out/dhcpcd-1.3.3.tar.gz
  86.  
  87.  
  88.  
  89.  
  90.  
  91.   RedHat 5.0 users
  92.   
  93.  
  94.  
  95.  
  96.  
  97. DHCPcd configuration under RedHat 5.0 is really easy. All you need to do
  98. is start the Control Panel by typing
  99.  
  100.  
  101.  
  102.  
  103.  
  104. control-panel
  105.  
  106.  
  107.  
  108.  
  109.  
  110. Then select "Network Configuration" and under eth0 interface define
  111. DHCP as your protocol. Other parameters should be left blank.
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.   Token Ring network
  119.   
  120.  
  121.  
  122.  
  123.  
  124. If you are trying to run dhcpcd on the Token Ring Network it will not
  125. work.  This is the solution provided to me by
  126. Henrik Stoerner:
  127.  
  128.  
  129.  
  130. _The problem is that dhcpcd only knows about Ethernet cards. If it
  131. finds a Token-Ring card, it refuses to do anything with it and reports
  132. "interface is not ethernet".
  133.  
  134.  
  135.  
  136. The solution is to apply a simple patch to the dhcpcd-0.65 sources. I
  137. have put up a small web page with the patch, RedHat RPM-files and a
  138. precompiled binary at http://eolicom.olicom.dk/~storner/dhcp/
  139.  
  140.  
  141.  
  142. The patch has been sent to the dhcpcd maintainer, so hopefully it will
  143. be included in a future release of dhcpcd.
  144. _
  145.  
  146.  
  147.  
  148.  
  149.  
  150.   Method
  151.   
  152.  
  153.  
  154. _Step 1)_ No matter what distribution you are using you will need
  155. to download the DHCP client daemon for Linux. The package you need to download
  156. is called dhcpcd and the current version is 0.70. The description
  157. of the package reads:
  158.  
  159.  
  160. Title:          dhcpcd
  161. Version:        0.70
  162. Entered-date:   05NOV97
  163. Description:    dhcpcd is an RFC2131 compliant DHCP client daemon. It
  164.                 gets an IP address and other information from a
  165.                 corresponding DHCP server, configures the network
  166.                 interface automatically, and tries to renew the lease
  167.                 time according to RFC2131. It works in the RFC1541
  168.                 compliant mode when the '-r' option is specified.
  169.                 So far it is found that dhcpcd 0.70 works with the
  170.                 following DHCP servers:
  171.                   1. ISC's dhcpcd-BETA-5.15
  172.                   2. DHCP server on Windows NT server 3.51
  173.                   3. DHCP server version 1.3b by WIDE project.
  174.                   4. DHCP server in the SolarNet PC-Admin 1.5 package
  175.                   5. DHCP server used in Time Warner Cable's
  176.                      Internet Access Service
  177.                   6. DHCP server used in Bell Atlantic ADSL
  178.                 See the "Changes" file if you want to know the difference
  179.                 from the previous version.
  180. Keywords:       DHCP, client, Linux
  181. Author:         yoichi@fore.com (Yoichi Hariguchi)
  182. Maintained-by:  yoichi@fore.com (Yoichi Hariguchi)
  183. Primary-site:   ftp.kobe-u.ac.jp /pub/PC-UNIX/Linux/network/dhcp
  184.                 33kB dhcpcd-0.70.tar.gz
  185. Alternate-site: sunsite.unc.edu /pub/Linux/system/Network/daemons
  186.                 33kB dhcpcd-0.70.tar.gz
  187. Original-site:
  188. Platforms:       Linux 1.2.xx, 1.3.xx, 2.0.x
  189. Copying-policy: GPL
  190.  
  191.  
  192.   Slackware
  193.   
  194.  
  195.  
  196. You can download the latest copy of the DHCPcd from any sunsite mirror
  197. or following:
  198.  
  199. ftp://ftp.cdrom.com/pub/linux/sunsite/system/network/daemons/.
  200.  
  201.  
  202. ftp://sunsite.unc.edu/pub/Linux/system/network/daemons
  203.  
  204.  
  205. ftp://ftp.kobe-u.ac.jp/pub/PC-UNIX/Linux/network/dhcp
  206. (Primary site in Japan)
  207.  
  208.  
  209.  
  210. Download the latest version of dhcpcd.tar.gz
  211.  
  212. Unpack it
  213.  
  214. tar -zxvf dhcpcd-0.70.tar.gz
  215.  
  216. cd into the directory
  217.  
  218. cd dhcpcd-0.70
  219.  
  220. make
  221.  
  222. You need to be root to do the following
  223.  
  224. make install
  225.  
  226.  
  227.  
  228. This will create the directory /etc/dhcpc where DHCPcd will store the
  229. DHCP information and dhcpcd file will be copied into /usr/sbin.
  230. Now skip to Step 2
  231.  
  232.   RedHat
  233.   
  234.  
  235.  
  236. DHCPcd is included in the standard RedHat distribution as an RPM and
  237. you can find it on your distribution's CD-ROM in RPMS directory or you can
  238. download it from:
  239.  
  240.  
  241. ftp://tsx-11.mit.edu/pub/linux/distributions/redhat/redhat-4.2/i386/RedHat/RPMS
  242. /dhcpcd-0.6-2.i386.rpm.
  243.  
  244.  
  245.  
  246.  
  247. and install it with
  248.  
  249. rpm -i dhcpcd-0.6-2.i386.rpm
  250.  
  251.  
  252.  
  253. Alternatively you can compile your own version by following the steps
  254. outlined in the Slackware part. When done go to Step 2
  255.  
  256.   Debian
  257.   
  258.  
  259.  
  260. There is deb package of DHCPcd at
  261.  
  262. ftp://ftp.debian.org/debian/stable/binary/net/
  263.  
  264.  
  265.  
  266.  
  267. or you can follow the Slackware installation instructions.
  268.  
  269.  
  270.  
  271. In order to unpack the deb package type
  272.  
  273. dpkg -i /where/ever/your/debian/packages/are/dhcpd*deb
  274.  
  275.  
  276.  
  277. When done go to Step 2
  278.  
  279.  
  280.  
  281.  
  282.  
  283.   __________________________________________________________________________
  284.  
  285.  
  286.  
  287.  
  288.  
  289. _Step 2)_
  290.  
  291.  
  292.  
  293.  
  294.  
  295. Following step(s) are depended on your needs.
  296.  
  297.  
  298.  
  299. _a) _ If you need network connectivity only occasionally you can
  300. start dhcpcd from the command line (you need to be root to execute it)
  301. by typing
  302.  
  303.  
  304.  
  305. /usr/sbin/dhcpcd
  306.  
  307. When you need to down (turn off) the network type
  308.  
  309. /usr/sbin/dhcpcd -k
  310.  
  311.  
  312.  
  313.  
  314.  
  315. You now only lack nameservers configuration file (/etc/resolv.conf).
  316. For instructions on how to create a resolv.conf go to
  317. Step 3
  318.  
  319.  
  320.  
  321.  
  322.  
  323. _b) _ If you want (need) network connectivity all the time and would
  324. like dhcpcd to start at boot time follow the steps below.
  325.  
  326.  
  327.  
  328.  
  329.  
  330.   Slackware
  331.   
  332.  
  333.  
  334. In order to make the system initialize using DHCP during boot type:
  335.  
  336.  
  337. cd /etc/rc.d
  338. mv rc.inet1 rc.inet1.OLD
  339.  
  340.  
  341.  
  342.  
  343.  
  344. This will move the old network initialization script into rc.inet1.OLD.
  345. You now need to create the new rc.inet1. It should look as follows:
  346.  
  347. #!/bin/sh
  348. #
  349. # rc.inet1      This shell script boots up the base INET system.
  350. #
  351. # Version:      @(#)/etc/rc.d/rc.inet1  1.01    05/27/93
  352. #
  353.  
  354. HOSTNAME=`cat /etc/HOSTNAME` #This is probably not necessary but I
  355.                              #will leave it in anyways
  356.  
  357. # Attach the loopback device.
  358. /sbin/ifconfig lo 127.0.0.1
  359. /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
  360.  
  361. # IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the
  362. # eth0 interface. If you're only using loopback or SLIP, don't include the
  363. # rest of the lines in this file.
  364.  
  365. /usr/sbin/dhcpcd
  366.  
  367.  
  368.  
  369.  
  370.  
  371. Save the above file as rc.inet1. Reboot your computer. Go to Step
  372. 3.
  373.  
  374.  
  375.  
  376.  
  377.  
  378.   RedHat
  379.   
  380.  
  381.  
  382. This information was provided to me by nothing (nothing@cc.gatech.edu)
  383.  
  384.  
  385.  
  386.  Removed my static ip and name from /etc/resolv.conf. However, I
  387. did leave in the search line and my two nameserver lines (for some reason my
  388. dhcpcd never creates a /etc/dhcpc/resolv.conf, so I have to use a static
  389. /etc/resolv.conf).
  390.  
  391.  
  392.  
  393.  In /etc/sysconfig/network I removed the HOSTNAME and GATEWAY
  394. entries.
  395. I left the other entries as is (NETWORKING, DOMAINNAME, GATEWAYDEV).
  396.  
  397.  
  398.  
  399.  In /etc/sysconfig/network-scripts/ifcfg-eth0 I removed the IPADDR,
  400. NETMASK, NETWORK, and BROADCAST entries. I left DEVICE and ONBOOT as is.
  401. I changed the BOOTPROTO line to BOOTPROTO=dhcp.
  402.  
  403.  
  404.  
  405. Save the file. Reboot your computer and go to Step 3
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.   Debian
  413.   
  414.  
  415.  
  416. It appears that there isn't a need for any DHCPcd configuration because:
  417.  
  418. From: Heiko Schlittermann
  419.  
  420.  
  421.  
  422.  The dhcpcd package installs it's startup script as usual for debian
  423. packages in /etc/init.d/, here as /etc/init.d/dhcpcd,
  424. and links this to the various /etc/rc?.d/ directories.
  425.  
  426.  
  427.  
  428. The contents of the /etc/rc?.d/ dirs is then executed at boot time.
  429.  
  430.  
  431.  
  432.  If you don't reboot after installing you should consider starting
  433. the daemon manually:
  434.  
  435.  
  436.  
  437. /etc/init.d/dhcpcd start
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445. Go to Step 3.
  446.  
  447.  
  448.  
  449.  
  450.  
  451.   __________________________________________________________________________
  452.  
  453.  
  454.  
  455.  
  456.  
  457. _Step 3)_ This step should be the same for all
  458. distributions.
  459.  
  460.  
  461.  
  462. After your machine reboots your network interface should be configured.
  463. Type:
  464.  
  465. ifconfig
  466.  
  467.  
  468.  
  469. You should get something like this
  470.  
  471. lo        Link encap:Local Loopback
  472.           inet addr:127.0.0.1  Bcast:127.255.255.255  Mask:255.0.0.0
  473.           UP BROADCAST LOOPBACK RUNNING  MTU:3584  Metric:1
  474.           RX packets:302 errors:0 dropped:0 overruns:0 frame:0
  475.           TX packets:302 errors:0 dropped:0 overruns:0 carrier:0 coll:0
  476.  
  477. eth0      Link encap:Ethernet  HWaddr 00:20:AF:EE:05:45
  478.           inet addr:24.128.53.102  Bcast:24.128.53.255  Mask:255.255.254.0
  479.           ^^^^^^^^^^^^^^^^^^^^^^^
  480.           UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
  481.           RX packets:24783 errors:1 dropped:1 overruns:0 frame:1
  482.           TX packets:11598 errors:0 dropped:0 overruns:0 carrier:0 coll:96
  483.           Interrupt:10 Base address:0x300
  484.  
  485.  
  486.  
  487.  
  488. If you have some normal number under inet. addr you are set. DHCPcd is a
  489. daemon and will stay running as long as you have your machine on. Every three
  490. hours it will contact the DHCP server and try to renew the IP address lease. It
  491. will log all the messages to the syslog (on Slackware /var/adm/syslog) if you
  492. need to check up on it.
  493.  
  494.  
  495.  
  496. One final thing. You need to specify your nameservers. There are two ways to do
  497. it, you can either ask your provider to provide you with the addresses of your
  498. name server and then put those in the /etc/resolv.conf or DHCPcd will obtain
  499. the list from the DHCP server and will build a resolv.conf in /etc/dhcpc.
  500. I decided to use DHCPcds resolv.conf by doing the following:
  501.  
  502. Back up your old /etc/resolv.conf
  503.  
  504. mv /etc/resolv.conf /etc/resolv.conf.OLD
  505.  
  506. If directory /etc/dhcpc doesn't exist create it
  507.  
  508. mkdir /etc/dhcpc
  509.  
  510. Make a link from /etc/dhcpc/resolv.conf to /etc/resolv.conf
  511.  
  512. ln -s /etc/dhcpc/resolv.conf /etc/resolv.conf
  513.  
  514.  
  515.  
  516.  If that doesn't work try this
  517. (fix suggested by nothing@cc.gatech.edu with a little amendment by Henrik
  518. Stoerner)
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  This last step I had to perform only because my dhcpcd doesn't
  527. create an /etc/dhcpc/resolv.conf.  In /etc/sysconfig/network-scripts/ifup I
  528. made the following changes (which are a very poor hack, but they work
  529. for me):
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537. #################################
  538. elif [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no ]; then
  539.     echo -n "Using DHCP for ${DEVICE}... "
  540.     /sbin/dhcpcd -c /etc/sysconfig/network-scripts/ifdhcpc-done ${DEVICE}
  541.     echo "echo \$$ > /var/run/dhcp-wait-${DEVICE}.pid; exec sleep 30" | sh
  542.  
  543.     if [ -f /var/run/dhcp-wait-${DEVICE}.pid ]; then
  544.         ^^^^
  545.         echo "failed."
  546.         exit 1
  547. #################################
  548.  
  549.  
  550.  
  551.  
  552.  
  553. I changed to:
  554.  
  555.  
  556.  
  557.  
  558. #################################
  559. elif [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no ]; then
  560.     echo -n "Using DHCP for ${DEVICE}... "
  561.     /sbin/dhcpcd
  562.     echo "echo \$$ > /var/run/dhcp-wait-${DEVICE}.pid; exec sleep 30" | sh
  563.  
  564.     if [ ! -f /var/run/dhcp-wait-${DEVICE}.pid ]; then
  565.         ^^^^^^
  566.        echo "failed."
  567.        exit 1
  568. #################################
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575. Notice the ! (bang) in if [ ! -f /var/run/dhcp-wait-${DEVICE}.pid ];
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584. Now sit back and enjoy :-).
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.   Troubleshooting
  593.   
  594.   
  595.  
  596.  
  597.  
  598.  
  599. If you have followed the steps outlined above and you are unable to access
  600. the network there are several possible explanations:
  601.  
  602.  
  603.  
  604.  
  605.  
  606. I. Your network card is not configured properly.
  607.  
  608.  
  609.  
  610. During the boot up
  611. process your Linux will probe your network card and should say something along
  612. these lines:
  613.  
  614. eth0: 3c509 at 0x300 tag 1, 10baseT port, address  00 20 af ee 11 11, IRQ 10.
  615. 3c509.c:1.07 6/15/95 becker@cesdis.gsfc.nasa.gov
  616.  
  617.  
  618. If a message like this doesn't appear your ethernet card might not be recognize
  619. d
  620. by your Linux system. If you have a generic ethernet card (a NE2000 clone) you
  621. should have received a disk with DOS utilities that you can use to set up
  622. the card. Try playing with IRQs until Linux recognizes your card (IRQ
  623. 9,10,12 are usually good).
  624.  
  625.  
  626.  
  627.  
  628.  
  629. II. Your DHCP server supports RFC 1541
  630.  
  631.  
  632.  
  633. Try running dhcpcd by typing
  634.  
  635.  
  636.  
  637. dhcpcd -r
  638.  
  639.  
  640.  
  641. Use ifconfig to check if your network interface is configured (wait few seconds
  642. for the configuration process, initally it will say Inet.addr=0.0.0.0)
  643.  
  644.  
  645.  
  646. If this solves your problem add the "-r" flag to the boot up scripts from Step
  647. 2)
  648. ie. instead of /sbin/dhcpcd you will have /sbin/dhcpcd -r
  649.  
  650.  
  651.  
  652.  
  653. III. During bootup I get error message "Using DHCP for eth0 ... failed"
  654. but my system works fine.
  655.  
  656.  
  657.  
  658.  
  659.  
  660. You are most likely using RedHat and you haven't followed instructions
  661. acurately :-). You are missing the ! (bang) in one of the if statements Jump ba
  662. ck up and read it again.
  663.  
  664.  
  665.  
  666.  
  667.  
  668. _IV. My network works for few minutes and then stops responding_
  669.  
  670.  
  671.  
  672.  
  673.  
  674. There are some reports of gated (gateway daemon) screwing up routing on
  675. Linux boxes which results in problem described above. Check if gated is
  676. running
  677.  
  678.  
  679.  
  680.  
  681. ps -auxww | grep gate
  682.  
  683.  
  684.  
  685.  
  686.  
  687. If it is try removing it with RedHat's RPM manager or removing the entry
  688. in /etc/rc.d/
  689.  
  690.  
  691.   __________________________________________________________________________
  692.  
  693.  
  694.  
  695.  
  696.  
  697. Thanks to all the people that contributed with their ideas and
  698. suggestions. Especially the following:
  699.  
  700.  
  701.  
  702. Heiko Schlittermann (heiko@os.inf.tu-dresden.de)
  703.  
  704. Jonathan Smith (jps2@ra.msstate.edu)
  705.  
  706. Dan Khabaza (danyh@iil.intel.com)
  707.  
  708. Hal Sadofsky (sadofsky@math.uoregon.edu)
  709.  
  710. Henrik Stoerner (henrik_stoernet@olicom.dk)
  711.  
  712. Paul Rossington (paulrossington@unn.unisys.com)
  713.  
  714.  
  715.  
  716.